﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TianShu.Service.Contracts.Service.Crud;
using TianShu.Service.Dtos;

namespace TianShu.WebApi
{
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class TianShuInsertController<TCreateDto, TDetailDto> : TianShuController
    {
        IInsertService<TCreateDto, TDetailDto> InsertService;
        public TianShuInsertController(IInsertService<TCreateDto, TDetailDto> insertService)
        {
            this.InsertService = insertService;
        }

        [HttpPut("insert")]
        public virtual async Task<IActionResult> Insert([FromBody] TCreateDto input)
        {
            var result = await InsertService.InsertAsync(input);
            return Json(result);
        }
    }
    public class TianShuInsertController<TCreateDto> : TianShuInsertController<TCreateDto, TCreateDto>
    {
        public TianShuInsertController(IInsertService<TCreateDto, TCreateDto> insertService) : base(insertService)
        {
        }

    }
}
